package com.woniuxy.service.impl;

import com.woniuxy.dao.MenumDao;
import com.woniuxy.entity.RbacMenu;
import com.woniuxy.entity.RbacPerm;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.entity.UpRoleDTO;
import com.woniuxy.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO:
 * <P> Date: 2022/2/24:17:35
 * <P> Description:
 */
@Service
public class PermServiceImpl implements MenuService {
    @Autowired(required = false)
    MenumDao menumDao;

    @Override
    public ResponseEntity findAll() {
        List<RbacPerm> perms = menumDao.findAll();
        if (perms.size() > 0) {
            return new ResponseEntity(200, "菜单查询成功", perms);
        } else {
            return new ResponseEntity(500, "菜单查询失败", null);
        }
    }

    @Override
    public ResponseEntity updateOne(Integer targetNode,Integer fatherNode) {
        int num = menumDao.updateOne(fatherNode, targetNode);
        if (num > 0) {
            return new ResponseEntity(200, "更新成功", null);
        } else {
            return new ResponseEntity(500, "更新失败", null);
        }

    }

    @Override
    public ResponseEntity updateMenus(RbacMenu rbacMenu) {
        int num = menumDao.updateMenus(rbacMenu);
        if (num > 0) {
            return new ResponseEntity(200, "更新成功", null);
        } else {
            return new ResponseEntity(500, "更新失败", null);
        }
    }
}


